/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package advanced_class_design.use_enumerated_types;

/**
 *
 * @author arifnasution
 */
public class SampleEnum3
{
    public enum MathOperation
    {
        plus
        {
            @Override
            double apply(double x, double y)
            {
                double temp = 0;
                temp = ( x + y );
                return temp;
            }
        },
        minus
        {
            @Override
            double apply(double x, double y)
            {
                double temp = 0;
                temp = ( x - y );
                return temp;
            }
        },
        divide
        {
            @Override
            double apply(double x, double y)
            {
                double temp = 0;
                temp = ( x / y );
                return temp;
            }
        },
        times
        {
            @Override
            double apply(double x, double y)
            {
                double temp = 0;
                temp = ( x + y );
                return temp;
            }
        };
        
        abstract double apply (double x, double y);
    }
    
    public static void main( String args[] )
    {
        MathOperation mathOperation = MathOperation.plus;
        System.out.println( "mathoperation (10+15) " + mathOperation.apply( 10, 15) );
    }
}
